﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mads.WcfService
{
  class TicketsGenerator
  {
    public TicketsGenerator()
    {
      lastCreation = trainBaseConnector.GetLastTicketCreation();
      GenerateTickets();
    }
    private static DateTime lastCreation;
    TrainBaseConnector trainBaseConnector = TrainBaseConnector.Instance;
    public void GenerateTickets()
    {
      TimeSpan timeSpan= DateTime.Now - lastCreation;
      for (int i = 0; i < Math.Min(40, timeSpan.Days); i++)
      {
        DateTime generateDate = DateTime.Today.AddDays(40 - i);
        trainBaseConnector.AddRaces(generateDate);
        trainBaseConnector.AddSeats(generateDate);
        trainBaseConnector.AddTickets(generateDate);
      }
    }
  }
}
